package com.atguigu.easyexcel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.atguigu.easyexcel.entity.StudentExcelData;
import org.apache.commons.lang3.RandomUtils;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


public class ExcelWriteTest03 {
    @Test
    public void testWrite03() {
        String pathName = "C:/Users/push/Desktop/file/excel" ;
        //write(String pathName, Class head)
        EasyExcel.write(pathName+ ExcelTypeEnum.XLS.getValue())
                .head(StudentExcelData.class)
                .sheet(0)
                .doWrite(data());
    }

    public List<StudentExcelData> data() {
        List<StudentExcelData> data = new ArrayList<>() ;
        for (int i = 0; i < 65536; i++) {
            StudentExcelData studentExcelData = new StudentExcelData() ;
            studentExcelData.setName("Nancy"+i);
            studentExcelData.setAge(RandomUtils.nextInt(16,28));
            studentExcelData.setBirthday(new Date());
            studentExcelData.setSalary(RandomUtils.nextDouble(10000,40000));
            data.add(studentExcelData) ;
        }
        return data ;
    }
}
